package history

import "sort"

/**
 * @description: 回响科技
 * @keyword:
 * @author: kami
 * @date 2023/12/14 18:08
 */
func findTopN(nums []int) int {
	// 1.全部排序
	sort.Ints(nums)
	// 2.小顶堆

	// 3.自己维护一个长度为N的有序数组
	return 0
}

func quickSort20231214(nums []int) {
	quickSortDfs(nums, 0, len(nums)-1)
}

func quickSortDfs20231214(nums []int, left, right int) {
	if left < right {
		var low = left
		var high = right
		var pvot = nums[low]
		for low < high {
			for low < high && nums[high] > pvot {
				high--
			}
			if low < high {
				nums[low] = nums[high]
				low++
			}
			for low < high && nums[low] < pvot {
				low++
			}
			if low < high {
				nums[high] = nums[low]
				high--
			}
		}
		nums[low] = pvot
		quickSortDfs(nums, left, low-1)
		quickSortDfs(nums, low+1, right)
	}
}
